package paper.web.controller.perform;

import org.apache.commons.lang3.RandomStringUtils;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import paper.dao.AccessoryDao;
import paper.domain.Accessory;
import paper.web.controller.BaseController;

@Controller
@RequestMapping("/perform")
public class PerformController extends BaseController {
	
	@Autowired
	AccessoryDao cdao;
	
	Long paperId;
	
	/**
	 * Logger for this class
	 */
	private static final Logger logger = LoggerFactory.getLogger(PerformController.class);
	
	public static class Views {
		private static final String Prefix = "perform";
		static final String Index = to_(Prefix) + "index";
		static final String Add = to_(Prefix) + "add";
	}
	
	/**
	 * <p>Method ：login
	 * <p>Description : 处理控制台请求
	 * @return 
	 * @author  gulixing@msn.com
	 * @version 1.0.0
	 */
	@RequestMapping(value = Routes.Index, method = RequestMethod.GET)
	public String confirm(Model model) {
		return Views.Index;
	}
	
	@RequestMapping(value = "/add", method = RequestMethod.GET)
	public String add() {	
		Accessory  acc = new Accessory();
		acc.setName("haha");
		acc.setRemark(RandomStringUtils.randomAlphabetic(5)+"——"+DateTime.now().toString());
		acc.setFilePath("filePath filePath filePath filePath");
    	cdao.save(acc);
    	return Views.Index;
	}
	
	@RequestMapping(value = "/get", method = RequestMethod.GET)
	@ResponseBody
	public String get() {	
		return "done";
	}
	
}